package Action;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import Utils.SendSMSHelper;

import Beans.Admin;
import Beans.ConfUpdate;
import DAO.AdminDao;
import DAO.ConfUpdateDao;
import DAO.IPDao;

public class IPAction {

	private int terminalId;
	private int status;
	private int updateid;
	private String name = "lblxyh.xicp.net";
	private String ip;
	private String msg;
	private String funId;
	private String message;
	private String phoneNum;
	private String loginName;
	private String loginPwd;

	private List<ConfUpdate> confUpdates;
	private List<Admin> admins;

	AdminDao adminDao = new AdminDao();
	IPDao ipDao = new IPDao();
	ConfUpdateDao confUpdateDao = new ConfUpdateDao();

	public String getIP() {
		ip = ipDao.getIP(name);
		return "success";
	}

	public String doPost() {
		ipDao.doPost(terminalId, status);
		return "success";
	}

	/**
	 * 新版短信平台
	 * http://localhost/YouBoxAdmin/sendMessage?message=你好&funId=7777&phoneNum=13599999999&loginName=admin&loginPwd=admin
	 */
	public String sendMessage() throws Exception {
//		admins = adminDao.adminLogin(loginName, loginPwd);
//		if ("7777".equals(funId) && admins.size() == 1) {
//			if (SendSMSHelper.newSend(message, phoneNum)) {
//				msg = "success:1";
//			} else {
//				msg = "error:-1";
//			}
//		} else {
//			msg = "error:-1";
//		}
//		ServletActionContext.getResponse().getWriter().print(msg);
		return null;
	}

	public String doUpdate() {
		ipDao.doUpdate(terminalId, updateid);
		return "success";
	}

	public String getConfUpdate() {
		confUpdates = confUpdateDao.getAll();
		return "success";
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getTerminalId() {
		return terminalId;
	}

	public void setTerminalId(int terminalId) {
		this.terminalId = terminalId;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public List<ConfUpdate> getConfUpdates() {
		return confUpdates;
	}

	public void setConfUpdates(List<ConfUpdate> confUpdates) {
		this.confUpdates = confUpdates;
	}

	public int getUpdateid() {
		return updateid;
	}

	public void setUpdateid(int updateid) {
		this.updateid = updateid;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getFunId() {
		return funId;
	}

	public void setFunId(String funId) {
		this.funId = funId;
	}

	public String getPhoneNum() {
		return phoneNum;
	}

	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getLoginPwd() {
		return loginPwd;
	}

	public void setLoginPwd(String loginPwd) {
		this.loginPwd = loginPwd;
	}

	public List<Admin> getAdmins() {
		return admins;
	}

	public void setAdmins(List<Admin> admins) {
		this.admins = admins;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

}
